<%
  form_options = {
    model: current_user,
    url: profile_path,
    scope: :profile,
    method: :put,
    class: 'edit-profile',
    data: { turbo: false }
  }
%>

<%= form_with(**form_options) do |f| %>

  <% if current_user.errors.any? %>
    <div class="alert alert-error">
      <%= current_user.errors.full_messages.to_sentence.capitalize %>
    </div>
  <% end %>

  <div class="flex gap-4 ">
    <fieldset class="fieldset grow w-1/2">
      <%= f.label :timezone, class: "fieldset-label" do %>
        <i class='ti ti-timezone'></i>
        <%= User.human_attribute_name(:timezone) %>
      <% end %>

      <div class="w-full flex justify-stretch">
        <%= f.select :timezone,
          ActiveSupport::TimeZone.all.sort_by(&:utc_offset).map{|e| ["#{e.name} (GMT#{e.now.formatted_offset})", e.name]},
          { include_blank: true },
          { class: "w-full", required: true,data: { controller: 'select2' } } %>
      </div>
      <span class="fieldset-legend text-base-content/70">
        <%= t(".why_is_timezone_needed") %>
      </span>
    </fieldset>

    <fieldset class="fieldset grow w-1/2">
      <%= f.label :locale, class: "fieldset-label" do %>
        <i class='ti ti-globe'></i>
        <%= User.human_attribute_name(:locale) %>
      <% end %>

      <%= f.select :locale, [['English', 'en'], ['Português (Brasil)', 'pt-BR']], { selected: I18n.locale }, { class: "select w-full" } %>
    </fieldset>
  </div>

  <div class="flex justify-end">
    <%= f.button t('actions.update'), class: "btn btn-primary" %>
  </div>
<% end %>
